<link href="books.css" rel="stylesheet" type="text/css" media="all"/>

<div class="list">
	<div class="title_book">
		<h2>Thể loại</h2>
	</div>
	<ul class="list_cat">
	<?php 
	$cats	=	get_all_cat();
	foreach($cats as $v):
	?>
		<li><a <?php echo (isset($_GET['cat']) && $_GET['cat'] == $v['pl_id'] ? 'class="current"' : '');?> href="index.php?act=list_books&cat=<?php echo $v['pl_id'];?>"><?php echo $v['pl_title'];?></a></li>
	<?php endforeach;?>
	</ul>
</div>

<div id="books">
<div class="title_book">
	<h2>Danh mục tài liệu</h2>
</div>
<?php 
$p	=	(isset($_GET['p']) ? $_GET['p'] : 1);
$limit	=	12;
$offset	=	($p-1)*$limit;
$where	=	(isset($_GET['cat']) ? ' AND pl_id='.intval($_GET['cat']) : '');
$q	=	mysql_query("SELECT * FROM tailieu WHERE 1".$where." ORDER BY tl_date DESC LIMIT $offset,$limit");
$q2	=	mysql_query("SELECT tl_id FROM tailieu WHERE 1".$where);
$num_rows	=	mysql_num_rows($q2);
$pagnav	=	pagination('index.php?act=list_docs'.(isset($_GET['cat']) ? '&cat='.$_GET['cat'] : ''),$num_rows,$limit,$p);

?>
<ul id="list">
  <?php while($book	=	mysql_fetch_array($q)):?>	
  <li>
  	<div class="book_100">
		<p class="bookbr">
			<a class="book_pic" href="index.php?act=view_doc&id=<?php echo $book['tl_id'];?>" title="<?php echo $book['tl_title'];?>">
				<img width="70" height="90" src="images/doc24x30.gif" alt="<?php echo $book['tl_title'];?>" onerror="this.src='<?php echo $CONFIG['site_url'].'images/onerror_72.jpg';?>'" /></a></p>
	  </div>
	  <p class="book_name">
		<a class="book_heading" href="index.php?act=view_doc&id=<?php echo $book['tl_id'];?>" title=''><?php echo $book['tl_title'];?></a></p>
  	
  </li>
  <?php endwhile;?>
  
</ul>
</div>
<?php echo $pagnav;?>